﻿using BrightIdeasSoftware;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BO;
using System.Collections;
using UI.Core;
using System.Data.SqlClient;
using System.Data.Entity;
namespace UI
{
    public partial class PrincipalGameReport : ReportFormBase,IMenuForm
    {
        public PrincipalGameReport()
        {
            InitializeComponent();
        }

        protected override void InitGrid()
        {
            
            MyGrid.Columns.AddRange(new OLVColumn[] { 
               
                 new OLVColumn("甲方", "PrincipalA"),
                   new OLVColumn("PK", "PK"),
                  new OLVColumn("乙方", "PrincipalB"),

                new OLVColumn("甲方单位", "AreaA"),
                new OLVColumn("甲方已达成", "ReachedAmountA"),
                new OLVColumn("甲方业绩目标", "AmountA"),
                new OLVColumn("甲方达成率(%)", "RateA"),

                new OLVColumn("乙方单位", "AreaB"),
                new OLVColumn("乙方已达成", "ReachedAmountB"),
                new OLVColumn("乙方业绩目标", "AmountB"),
                new OLVColumn("乙方达成率(%)", "RateB"),

            
            });

           
        }
        IEnumerable mySource;

        protected override IEnumerable MySource
        {
            get
            {
                return mySource;
            }
        }
        protected override void FetchData()
        {


            var data =ListFactory<PrincipalGameList>.GetList("");
            var targets = ListFactory<DateTargetsList>.GetList("");
            var b = ListFactory<BillingList>.GetList(" Billing.HasDeleted=0 and Billing.IsConfirm=1");
            var c=ListFactory<CompanyList>.GetList("");
            var center=ListFactory<CenterList>.GetList("");
            var d=ListFactory<DepartmentList>.GetList("");
            foreach (var item in targets)
            {
                item.LoadReachedAmount(b,c,center,d);
            }
            foreach (var item in data)
            {
                item.LoadData(targets);
            }
            mySource = data;
        }
    }
}
